//
//  HSPActivityTableViewCell.m
//  Icar
//
//  Created by dllo on 15/10/23.
//  Copyright © 2015年 小龙侠. All rights reserved.
//

#import "HSPActivityTableViewCell.h"
#import "BaseHeader.h"
@implementation HSPActivityTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creat];
    }
    return self;
}
- (void)creat
{
    self.photoLabel = [[UIImageView alloc]initWithFrame:CGRectMake(10 * ADJUSTWIDTH, 50 * ADJUSTHEIGHT, 120 * ADJUSTWIDTH, 80 * ADJUSTHEIGHT)];
    [self.contentView addSubview:self.photoLabel];
    
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 10,ADJUSTHEIGHT * 5, ADJUSTWIDTH * 320, ADJUSTHEIGHT * 30)];
    self.titleLabel.font =[UIFont systemFontOfSize:18. * ADJUSTWIDTH];
    self.titleLabel.numberOfLines = 0;
    [self.contentView addSubview:self.titleLabel];
    
    self.priceTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 140, ADJUSTHEIGHT*30, ADJUSTWIDTH * 240, ADJUSTHEIGHT * 50)];
    self.priceTitleLabel.font =[UIFont systemFontOfSize:14. * ADJUSTWIDTH];
    [self.priceTitleLabel setTextColor:[UIColor redColor]];
    self.priceTitleLabel.numberOfLines = 0;
    [self.contentView addSubview:self.priceTitleLabel];
    
    self.setialGroupNamesLabel = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 135, ADJUSTHEIGHT * 60, ADJUSTWIDTH * 220, ADJUSTHEIGHT * 50)];
    self.setialGroupNamesLabel.font =[UIFont systemFontOfSize:15. * ADJUSTWIDTH];
    self.setialGroupNamesLabel.textColor = [UIColor grayColor];
    self.setialGroupNamesLabel.numberOfLines = 0;
    [self.contentView addSubview:self.setialGroupNamesLabel];
    
    self.endTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 135, ADJUSTHEIGHT * 100, ADJUSTHEIGHT * 200, ADJUSTHEIGHT * 30)];
    self.endTimeLabel.font =[UIFont systemFontOfSize:14.* ADJUSTWIDTH];
    self.endTimeLabel.textColor = [UIColor grayColor];
    self.endTimeLabel.numberOfLines = 0;
    [self.contentView addSubview:self.endTimeLabel];
    
    self.orderCountLabel = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 280, ADJUSTHEIGHT * 100, ADJUSTHEIGHT * 80, ADJUSTHEIGHT * 30)];
    self.orderCountLabel.font =[UIFont systemFontOfSize:14.* ADJUSTWIDTH];
    self.orderCountLabel.numberOfLines = 0;
    self.orderCountLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.orderCountLabel];
    
    self.brandNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH * 15, ADJUSTHEIGHT * 55, ADJUSTHEIGHT * 200, ADJUSTHEIGHT * 30)];
    self.brandNameLabel .font =[UIFont systemFontOfSize:14.* ADJUSTWIDTH];
    self.brandNameLabel .numberOfLines = 0;
    self.brandNameLabel.textColor = [UIColor whiteColor];
    [self.photoLabel addSubview:self.brandNameLabel];
    
}
- (void)getActiviay:(HSPActivityModel *)modelActivity
{
    [self.photoLabel sd_setImageWithURL:[NSURL URLWithString:modelActivity.photo]placeholderImage:[UIImage imageNamed:@"1.jpg"]];
    self.titleLabel.text = modelActivity.title;
    if ([[modelActivity.maxDiscount description] isEqualToString:@"0"]) {
           self.priceTitleLabel.text = modelActivity.priceTitle;
    }
    else
    {
        [self.priceTitleLabel setText:[NSString stringWithFormat:@"￥最高优惠%@万",modelActivity.maxDiscount]];
    }
 
    [self.setialGroupNamesLabel setText:[NSString stringWithFormat:@"适用车系 : %@",modelActivity.serialGroupNames]];
    [self.endTimeLabel setText:[NSString stringWithFormat:@"%@截止",[modelActivity.endTime substringToIndex:10]]];
    [self.orderCountLabel setText:[NSString stringWithFormat:@"已报名%@人",[modelActivity.orderCount description]]];
    self.brandNameLabel.text = modelActivity.brandName;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
